home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / socketx / UDPPEERB.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-10-06  |  3.6 KB  |  119 lines

  1. VERSION 5.00
  2. Object = "{C7212F93-30E8-11D2-B450-0020AFD69DE6}#1.0#0"; "SocketX.OCX"
  3. Begin VB.Form UDPPeerB 
  4.    Caption         =   "UDPPeerB"
  5.    ClientHeight    =   2640
  6.    ClientLeft      =   4740
  7.    ClientTop       =   2715
  8.    ClientWidth     =   4080
  9.    KeyPreview      =   -1  'True
  10.    LinkTopic       =   "UDPPeerB"
  11.    LockControls    =   -1  'True
  12.    PaletteMode     =   1  'UseZOrder
  13.    ScaleHeight     =   2640
  14.    ScaleWidth      =   4080
  15.    Begin SocketXCtl.SocketXCtl SocketX 
  16.       Left            =   3240
  17.       Top             =   1560
  18.       _cx             =   847
  19.       _cy             =   847
  20.       AcceptTimeout   =   0
  21.       BlockingMode    =   -842150451
  22.       Blocking        =   -1  'True
  23.       BroadcastEnabled=   -1  'True
  24.       ConnectTimeout  =   0
  25.       EventMask       =   63
  26.       KeepAliveEnabled=   0   'False
  27.       LibraryName     =   "WSOCK32.DLL"
  28.       LingerEnabled   =   0   'False
  29.       LingerMode      =   0
  30.       LingerTime      =   0
  31.       LocalAddress    =   ""
  32.       LocalPort       =   0
  33.       OutOfBandEnabled=   0   'False
  34.       ReceiveBufferSize=   8192
  35.       ReceiveTimeout  =   0
  36.       RemoteAddress   =   ""
  37.       RemoteName      =   ""
  38.       ReuseAddressEnabled=   0   'False
  39.       RemotePort      =   0
  40.       RouteEnabled    =   -1  'True
  41.       SendTimeout     =   0
  42.       SendBufferSize  =   8192
  43.       SocketType      =   0
  44.       TcpNoDelayEnabled=   0   'False
  45.    End
  46.    Begin VB.ListBox lstTranscript 
  47.       Height          =   1230
  48.       Left            =   120
  49.       TabIndex        =   1
  50.       TabStop         =   0   'False
  51.       Top             =   360
  52.       Width           =   3855
  53.    End
  54.    Begin VB.TextBox txtSend 
  55.       Height          =   285
  56.       Left            =   120
  57.       TabIndex        =   0
  58.       Top             =   2040
  59.       Width           =   3855
  60.    End
  61.    Begin VB.Label Label1 
  62.       Caption         =   "Transcript:"
  63.       Height          =   255
  64.       Left            =   120
  65.       TabIndex        =   3
  66.       Top             =   120
  67.       Width           =   735
  68.    End
  69.    Begin VB.Label Label2 
  70.       Caption         =   "Enter message here then press Enter:"
  71.       Height          =   255
  72.       Left            =   120
  73.       TabIndex        =   2
  74.       Top             =   1800
  75.       Width           =   2655
  76.    End
  77. Attribute VB_Name = "UDPPeerB"
  78. Attribute VB_GlobalNameSpace = False
  79. Attribute VB_Creatable = False
  80. Attribute VB_PredeclaredId = True
  81. Attribute VB_Exposed = False
  82. Option Explicit
  83. ' The following variable is set during UDPPeerA's Form_Load event
  84. Public RemoteAddress As String
  85. Private Sub Form_KeyPress(KeyAscii As Integer)
  86.     If (KeyAscii = 13) Then
  87.         If (txtSend.Text <> "") Then
  88.             lstTranscript.AddItem "send: " & txtSend.Text
  89.             SocketX.SendTo RemoteAddress, 1, txtSend.Text
  90.             txtSend.Text = ""
  91.         End If
  92.         KeyAscii = 0
  93.     End If
  94. End Sub
  95. Private Sub Form_Unload(Cancel As Integer)
  96.    End
  97. End Sub
  98. Private Sub Form_Load()
  99.     '
  100.     ' set socket type to datagram
  101.     '
  102.     SocketX.SocketType = soxDatagram
  103.     SocketX.EventMask = -1
  104.     SocketX.Blocking = False
  105.     SocketX.LocalAddress = RemoteAddress
  106.     SocketX.LocalPort = 2
  107.     SocketX.Create
  108.     SocketX.Bind
  109. End Sub
  110. Private Sub SocketX_Receive(ByVal ErrorCode As Integer)
  111.     Dim s As String
  112.     '
  113.     ' Data received, add it to the transcript list
  114.     ' Use ReceiveFrom so we can pick up the sender's address
  115.     '
  116.     s = SocketX.ReceiveFrom
  117.     lstTranscript.AddItem SocketX.PeerAddress & ":" & SocketX.PeerPort & " sent: " & s
  118. End Sub
  119.